﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Pumpkin.FrameBase;
using Pumpkin.FrameBase.BaseModule;
using Pumpkin.FrameBase.DownLoader;
using Pumpkin.FrameBase.Resource;
using Pumpkin.FrameBase.ILRTPlugins;
using Pumpkin.FrameBase.KBEPlugins;
using Pumpkin.FrameBase.Template;
using Pumpkin.FrameBase.Scene;
using Pumpkin.Utils;

namespace Pumpkin.Framework
{
    public enum TriggerType
    {
        None,
        UpdateNotify,
        DownloadProcessing,
        InitProcessing,
        InitNext,
        InitFinish,
        Notify,
        Warnning,
        Error,
    }

    public static class HotFixMain
    {
        private static Trigger<TriggerType, object, object> trigger_ = new Trigger<TriggerType, object, object>();
        private static Queue<Action> initSeq_ = new Queue<Action>();

        public static void Startup(string resUrl, bool isDebug, bool enableHotfix, Action onStartupFinish)
        {
            GlobalConfigs.Instance.SetResUrl(resUrl);
            GlobalConfigs.Instance.SetMode(isDebug);
            GlobalConfigs.Instance.SetUseHotFix(enableHotfix);

            Log.SetLogger(new DbgAdapter());

            FrameModuleMgr.Instance.RegistAllModulesLoaded(onStartupFinish);
            FrameModuleMgr.Instance.AddModule(new BaseModule());
#if UNITY_EDITOR
            if (enableHotfix)
            {
                FrameModuleMgr.Instance.AddModule(new DownloadModule());
            }
#else
            FrameModuleMgr.Instance.AddModule(new DownloadModule());
#endif
            FrameModuleMgr.Instance.AddModule(new ResourceModule());
            FrameModuleMgr.Instance.AddModule(new ILRTModule());
            FrameModuleMgr.Instance.AddModule(new KBEngineModule());
            FrameModuleMgr.Instance.AddModule(new TemplateModule());
            FrameModuleMgr.Instance.AddModule(new SceneModule());
            //FrameModuleMgr.Instance.AddModule(new GameMainModule());
            FrameModuleMgr.Instance.BeginInit();
        }
    }
}

